<?php

namespace Plugins\AdminBasic\Http\Admin\Controller;

use App\Http\AbstractController;
use App\Middlewares\Admin\AuthenticateMiddleware;
use App\Middlewares\Admin\PermissionsMiddleware;
use App\Util\Response;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\GetMapping;
use Hyperf\HttpServer\Annotation\Middlewares;
use Hyperf\View\Render;
use Psr\Http\Message\ResponseInterface;
use Plugins\AdminBasic\Http\Admin\Service\OperationLogsService;
use Hyperf\HttpServer\Annotation\PostMapping;
use Hyperf\Validation\Annotation\Scene;
use App\Exception\ApiMessageException;
use Hyperf\Validation\Middleware\ValidationMiddleware;
use Plugins\AdminBasic\Requests\BasicOperationLogsRequest;
use Psr\SimpleCache\InvalidArgumentException;


/**
 * 操作日志
 */
#[Controller(prefix: 'admin/plugins/admin-basic/operation_logs')]
#[Middlewares([AuthenticateMiddleware::class, PermissionsMiddleware::class])]
class OperationLogsController extends AbstractController
{


    /**
     * 列表页
     * 
     * @param Render $render
     * 
     * @return ResponseInterface
     */
    #[GetMapping(path: 'lists')]
    public function lists(Render $render): ResponseInterface
    {
        return $render->render('plugins.AdminBasic.Admin.OperationLogs.lists');
    }

    /**
     * 列表数据
     * 
     * @return ResponseInterface
     */
    #[GetMapping(path: 'lists-data')]
    public function listsData(): ResponseInterface
    {
        return Response::json()->success(OperationLogsService::aop()->lists());
    }

    /**
     * 明细
     *
     * @param Render $render
     *
     * @return ResponseInterface
     */
    #[GetMapping(path: 'detail')]
    public function detail(Render $render): ResponseInterface
    {
        return $render->render('plugins.AdminBasic.Admin.OperationLogs.detail');
    }

    /**
     * 缓存路由描述
     */
    #[GetMapping(path: 'cache-route-des-map')]
    public function cacheRouteDesMap(): ResponseInterface
    {
        OperationLogsService::aop()->cacheRouteDes();

        return Response::json()->success();
    }
}